<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>example02</title>
  <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
  <h1>example02</h1>
  <hr>
  <div id="app">
    
  </div>
  <div><button onclick="destroy()">destroy</button></div>
  <div><button onclick="reload()">reload</button></div>
  <div><button onclick="tick()">tick</button></div>
  <script type="text/javascript">
  var adamWang = Vue.extend({
    template:'<p>{{message}}</p>',
    data:function(){
      return {
        message:'Hi,I am adamwang!'
      }
    },
    mounted:function(){
      console.log('mounted be created!');
    },
    destroyed:function(){
      console.log('destroyed 销毁之后');
    },
    updated:function(){
      console.log('updated 更新之后');
    }
  })
  var vm = new adamWang().$mount('#app');
  function destroy(){
    vm.$destroy();
  }
  function reload(){
    vm.$forceUpdate();
  }
  function tick(){
    vm.message = 'update message info.';
    //数据被修改之后的回调方法
    vm.$nextTick(function(){
      console.log('message更新完后我被调用了！');
    })
  }
  </script>
</body>
</html>